#include <stdio.h>

int** printStudentGrades(int n){
    int (*score)[n][5];
    int (*p)[5];
    for (p=score[0];*p; p++){
        scanf("%d%d%d%d%d", &p[0][0], &p[0][1], &p[0][2], &p[0][3], &p[0][4]);
    }
    return score;

}

void *findGrades(int number,int score[][5]){
    int (*p)[5];
    int i;
    for (p=&score,i=0;*p; p++,i++){
        if (*(p[0]+0)==number)break;
    }
    return p;
}

void main(){
    int n;
    scanf("%d",&n);
    int (*score)[n][5]=printStudentGrades(n);

    int number;
    scanf("%d",&number);
    int (*p)[5];
    p=findGrades(number,score);
    printf("%d %d %d %d",*(p[0]+1),*(p[0]+2),*(p[0]+3),*(p[0]+4));

}